Field of the Invention
The present invention relates to communication apparatuses capable of wireless communication with an external apparatus such as a mobile terminal, a PC, or the like, and to control methods thereof, printing apparatuses, and storage media.
Description of the Related Art
Recent years have seen an increase in printing apparatuses, such as multifunction peripherals, printers, and the like, that include wireless LAN functionality. A printing apparatus that includes wireless LAN functionality can connect wirelessly to an access point as a client using an infrastructure mode. Meanwhile, by using the infrastructure mode to communicate with the printing apparatus via the access point, PCs, mobile terminals, and the like can cause the printing apparatus to execute printing by sending print data thereto, and the PCs, mobile terminals, and the like can then be used to manage the printing apparatus by receiving device information from the printing apparatus.
Related to the aforementioned wireless LAN, the Wi-Fi Alliance has established a standard called Wi-Fi Direct®. Wi-Fi Direct defines a protocol for determining whether a wireless terminal will function as an access point or as a client. Which wireless terminal will function as an access point and which wireless terminal will function as a client can be determined automatically by executing this protocol. Using Wi-Fi Direct enables one of the wireless terminals to function as an access point automatically without needing to prepare a separate access point, which makes it possible for wireless terminals to wirelessly communicate with each other directly. Furthermore, using Wi-Fi Direct makes it possible to execute various types of application services (image sharing, printing, and the like) among wireless terminals.
Wi-Fi Direct-compliant printing apparatuses are configured so that a user can use a console or the like to manually instruct whether to use Wi-Fi Direct, or to use the infrastructure mode for wireless communication via a third-party access point, as a communication mode for communicating wirelessly with a communication partner. Such printing apparatuses are normally configured to use the infrastructure mode so that multiple users can use the printing apparatus. When it is necessary to use Wi-Fi Direct as the communication mode, a user may temporarily switch the communication mode of the printing apparatus from the infrastructure mode to Wi-Fi Direct and then return the communication mode to the infrastructure mode once the desired tasks have been completed.
However, such a printing apparatus has a problem in that if a given user forgets to return the communication mode to the infrastructure mode after temporarily using Wi-Fi Direct, other users who have been using the printing apparatus in the infrastructure mode will be rendered unable to use the printing apparatus. To solve this problem, the printing apparatus may, for example, automatically switch the communication mode from Wi-Fi Direct to the infrastructure mode rather than waiting for a user to instruct the communication mode to be switched.
Japanese Patent Laid-Open No. 2012-113349 proposes a method for automatically switching a communication mode in a printing apparatus. This document discloses a printing apparatus, capable of using the stated infrastructure mode or an ad-hoc mode for communicating directly with the terminal apparatus without going through an access point, that automatically switches the communication mode when communicating wirelessly with a terminal apparatus. Specifically, in the case where the printing apparatus is operating in the ad-hoc mode and a given instance of print data has not been received for a predetermined amount of time after printing has been completed based on a different instance of print data received from a terminal apparatus, the communication mode is automatically returned to the infrastructure mode. In this manner, the printing apparatus disclosed in Japanese Patent Laid-Open No. 2012-113349 automatically switches the communication mode from the ad-hoc mode to the infrastructure mode depending on the communication partner or the state of communication with the communication partner.
However, with the stated printing apparatus (communication apparatus), a situation can arise where it is desirable to automatically switch the communication mode at a timing based on an operation state of the printing apparatus regardless of the communication partner or the state of communication with the communication partner.
For example, recent printing apparatuses typically have power-saving functions for reducing power consumption by shifting from a normal operation state to a power saving state in which power is only supplied to some devices, such as a CPU, a memory, or the like. Such printing apparatuses shift from the normal operation state to the power saving state in the case where an instruction from a user has been received via an operation unit such as a console, the case where an instruction has been received from a server or the like via a network, the case where an idle state has continued for a predetermined amount of time, and so on. If a printing apparatus that has a power-saving function shifts from the normal operation state to the power saving state while operating using Wi-Fi Direct, the apparatus will continue to use Wi-Fi Direct in the power saving state as long as there is no event that shifts the apparatus back to the normal operation state. In such a situation, there is a problem in that a user who is using the printing apparatus through wireless communication in the infrastructure mode will be rendered unable to use the printing apparatus.